﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.Generic;

namespace CalculationDemo
{
    public class Unit : INotifyPropertyChanged
    {
        #region Variables

        private int unitID;
        private int parentUnitID;        
        private string unitName;
        private string unitType;
        private string fluidType;
        private double capacity;
        private double effectiveCapacity;
        private double realCapacity;
        private bool isBottleneck;
        //public List<UnitLayer> UnitLayerList { get; set; }
        public List<Unit> ChildUnitList { get; set; }
        public List<int> ParentUnitIDList { get; set; }
        #endregion

        #region Properties

        public int UnitID
        {
            get { return unitID; }
            set { unitID = value; }
        }

        public int ParentUnitID
        {
            get { return parentUnitID; }
            set { parentUnitID = value; }
        }

        public string UnitName
        {
            get { return unitName; }
            set { unitName = value; }
        }

        public string UnitType
        {
            get { return unitType; }
            set { unitType = value; }
        }

        public string FluidType
        {
            get { return fluidType; }
            set { fluidType = value; }
        }

        public double Capacity
        {
            get { return capacity; }
            set {
                  double b = double.Parse(value.ToString("0.00"));
                  //capacity = value; 
                  capacity = b;
                  onPropertyChanged(this, "Capacity"); }
        }

        public double EffectiveCapacity
        {
            get { return effectiveCapacity; }
            set
                {
                   double b = double.Parse(value.ToString("0.00"));
                   effectiveCapacity = b;                 
                   onPropertyChanged(this, "EffectiveCapacity"); 
                }
        }

        //decimal.Round(d,2)
        public double RealCapacity
        {
            get { return realCapacity; }
            set { 
                  double b = double.Parse(value.ToString("0.00"));
                  realCapacity = b;
                  //realCapacity = decimal.Round(realCapacity, 2);
                  onPropertyChanged(this, "RealCapacity"); }
        }

        public bool IsBottleNeck
        {
            get { return isBottleneck; }
            set { isBottleneck = value; onPropertyChanged(this, "IsBottleNeck"); }
        }


        #endregion


        // Declare the PropertyChanged event
        public event PropertyChangedEventHandler PropertyChanged;

        // OnPropertyChanged will raise the PropertyChanged event passing the source property that is being updated.
        private void onPropertyChanged(object sender, string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));
            }
        }

    }
}
